﻿//ChartCandleElement.cs
//Copyright (c) 2013 StockSharp LLC, all rights reserved.
//This code module is part of StockSharp library.
//This code is licensed under the GNU GENERAL PUBLIC LICENSE Version 3.
//See the file License.txt for the license details.
//More info on: http://stocksharp.com

namespace StockSharp.Xaml
{
	using System.ComponentModel;
	using System.Windows.Media;

	using Ecng.Serialization;

	/// <summary>
	/// Элемент графика, представляющий свечки.
	/// </summary>
	public class ChartCandleElement : ChartElement<ChartCandleElement>
	{
		/// <summary>
		/// Создать <see cref="ChartCandleElement"/>.
		/// </summary>
		public ChartCandleElement()
		{
			ColorPriceDown = Colors.Red;
			ColorPriceUp = Colors.Green;
		}

		/// <summary>
		/// Цвет тела убывающей свечи.
		/// </summary>
		[DisplayName("Убывание")]
		[Description("Цвет тела убывающей свечи.")]
		[Category(ViewCategory)]
		public Color ColorPriceDown { get; set; }

		/// <summary>
		/// Цвет тела возрастающей свечи.
		/// </summary>
		[DisplayName("Возрастание")]
		[Description("Цвет тела возрастающей свечи.")]
		[Category(ViewCategory)]
		public Color ColorPriceUp { get; set; }

		/// <summary>
		/// Загрузить настройки.
		/// </summary>
		/// <param name="storage">Хранилище настроек.</param>
		public override void Load(SettingsStorage storage)
		{
			base.Load(storage);

			ColorPriceDown = storage.GetValue<SettingsStorage>("ColorPriceDown").ToColor();
			ColorPriceUp = storage.GetValue<SettingsStorage>("ColorPriceUp").ToColor();
		}

		/// <summary>
		/// Сохранить настройки.
		/// </summary>
		/// <param name="storage">Хранилище настроек.</param>
		public override void Save(SettingsStorage storage)
		{
			base.Save(storage);

			storage.SetValue("ColorPriceDown", ColorPriceDown.ToStorage());
			storage.SetValue("ColorPriceUp", ColorPriceUp.ToStorage());
		}

		/// <summary>
		/// Создать копию элемента.
		/// </summary>
		/// <returns>Копия.</returns>
		public override ChartCandleElement Clone()
		{
			return FillClone(new ChartCandleElement
			{
				ColorPriceDown = ColorPriceDown,
				ColorPriceUp = ColorPriceUp,
			});
		}
	}
}